﻿using System.Text.Json.Serialization;
using WeChatBotSDK.Constants;

namespace WeChatBotSDK.Models
{
    /// <summary>
    /// 表示微信请求体。
    /// </summary>
    public record WeChatRequest<T>where T : class, new() 
    {
        /// <summary>
        /// 请求类型。
        /// </summary>
        [JsonPropertyName("type")] 
        public string Type { get; set; } =微信常量_接口请求.获取微信列表;

        /// <summary>
        /// 请求数据。
        /// </summary>
        [JsonPropertyName("data")] 
        public T Data { get; set; } = new T();
    }

    public record TextMessageRequest
    {
        /// <summary>
        /// 消息内容, 如果\n是两行，那么用\r试试
        /// </summary>
        [JsonPropertyName("msg")]
        public string Msg { get; set; }

        /// <summary>
        /// 对方wxid, 要给谁，支持好友、群聊、公众号等
        /// </summary>
        [JsonPropertyName("wxid")]
        public string Wxid { get; set; }
    }

    public record ImageOrFileMessageRequest
    {
        /// <summary>
        /// 保存文件名, 当path是网络直链时，必填
        /// </summary>
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
        [JsonPropertyName("fileName")]
        public string? FileName { get; set; }

        /// <summary>
        /// 文件本地路径或者网络直链或者base64, base64时，需要以 base64, 开头
        /// </summary>
        [JsonPropertyName("path")]
        public string Path { get; set; }

        /// <summary>
        /// 对方wxid, 要给谁，支持好友、群聊、公众号等
        /// </summary>
        [JsonPropertyName("wxid")]
        public string Wxid { get; set; }
    }

    public record FriendRemarkRequest
    {
        /// <summary>
        /// 新备注
        /// </summary>
        [JsonPropertyName("remark")]
        public string Remark { get; set; }

        [JsonPropertyName("wxid")]
        public string Wxid { get; set; }
    }
    public record ContactInfoRequest
    {
        /// <summary>
        /// 1=从缓存中获取，2=重新遍历二叉树并刷新缓存
        /// </summary>
        [JsonPropertyName("type")]
        public string Type { get; set; } = "1";
        /// <summary>
        /// 
        /// </summary>
        [JsonPropertyName("wxid")]
        public string Wxid { get; set; }
        /// <summary>
        /// 1=不获取昵称，2=获取群昵称（性能影响）
        /// </summary>
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
        [JsonPropertyName("getNick")]
        public string? GetNick { get; set; } = null;
    }

    public record GroupMemberNicknameRequest
    {
        /// <summary>
        /// 群wxid
        /// </summary>
        [JsonPropertyName("wxid")]
        public string Wxid { get; set; }
        /// <summary>
        /// 对方wxid
        /// </summary>
        [JsonPropertyName("objWxid")]
        public string ObjWxid { get; set; }
    }
    /// <summary>
    /// 下载图片时间的具体数据
    /// </summary>
    public class DownloadImageTimeData
    {
        /// <summary>
        /// 下载控制类型（使用枚举表示）
        /// 1 = 全天下载
        /// 2 = 全天不下载
        /// </summary>
        [JsonConverter(typeof(JsonStringEnumConverter))] // 用于将枚举值序列化为字符串
        public DownloadType Type { get; set; }
    }

    /// <summary>
    /// 修改微信版本号
    /// </summary>
    public class WeChatVersion
    {
        /// <summary>
        /// 微信版本号
        /// </summary>
        [JsonPropertyName("new")]
        public string New { get; set; }
    }
}
